#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author  : Lee
# @File    : utm_transformer.py
# @Time    : 2024/1/17 9:16
import csv
from pyproj import Transformer
# 参数1：WGS84地理坐标系统 对应 4326
# 参数2：坐标系日照 WGS_1984_UTM_Zone_50N 对应 32650
# 将rtk轨迹从WGS84坐标系转为UTM坐标系，并转换成局部坐标系，以便显示
transformer = Transformer.from_crs("epsg:4326", "epsg:32650")


def transformer_to_utm(lat, lon):
    return transformer.transform(lat, lon)


if __name__ == '__main__':
    _utm_list = list()
    with open("../data/pose_20240116150255.csv", "r") as csv_obj:
        for line in csv_obj.readlines():
            _line_list = line.strip().split(",")
            _utm_list.append([_line_list[0], *transformer_to_utm(*_line_list[-2:]), *_line_list[3:5]])

    with open("data/test_data.csv", 'w', newline='') as file:
        writer = csv.writer(file)
        writer.writerows(_utm_list)
# lat = 35.62176307109
# lon = 119.4722048511
#
# x, y = transformer.transform(lat, lon)
#
# print(x, y)
# # 723894.5891127 3944811.071756

